package com.cy.model;

import com.alibaba.fastjson.JSONObject;
import com.cy.BasicModel;
import com.cy.ext.plugin.tablebind.TableBind;

import java.util.Date;
import java.util.Set;

@SuppressWarnings("serial")
@TableBind(tableName="device_attr",pkName = "id")
public class DeviceAttr extends BasicModel<DeviceAttr> {
    public static final DeviceAttr dao = new DeviceAttr();
    public static final String SELECT_ALL = "`id`,`model_num`,`project_id`,`release_date`,`pic_url`,`type`,`description`,`heating_method`,`applicable_scope`,`communicating_method`,`default_connection_status`,`hardware_version_id`,`app_version_id`,`certificate_id`";

    /**
     * 连接属性
     */
    public enum ConnectionStatus{
        PRIVATE(0, "私有"),
        PUBLIC(1, "公有");

        private int value;
        private String name;

        ConnectionStatus(int value, String name) {
            this.value = value;
            this.name = name;
        }

        public String getName() {
            return name;
        }

        public int getValue() {
            return value;
        }

        public static JSONObject toJson(){
            JSONObject jsonObject = new JSONObject(values().length);
            for (ConnectionStatus item : values())
                jsonObject.put(String.valueOf(item.getValue()), item.getName());
            return jsonObject;
        }
    }

    /**
     * 通信方式:多选，做位运算
     */
    public enum CommunicatingMethod{
        BLE(1, "ble"),
        AIRSYNIC(2, "airsynic"),
        WIFI(4, "wifi"),
        OTHER(8, "other");

        private int value;
        private String name;

        CommunicatingMethod(int value, String name) {
            this.value = value;
            this.name = name;
        }

        public String getName() {
            return name;
        }

        public int getValue() {
            return value;
        }

        public static JSONObject toJson(){
            JSONObject jsonObject = new JSONObject(values().length);
            for (CommunicatingMethod item : values())
                jsonObject.put(String.valueOf(item.getValue()), item.getName());
            return jsonObject;
        }
    }

    /**
     * 适用场合:多选，做位运算
     */
    public enum ApplicableScope{
        PERSONAL_DESKTOP(1, "个人桌面"),
        PUBLIC_DESKTOP(2, "公众桌面"),
        PERSONAL_CARRYING(4, "个人便携"),
        BUSINESS(8, "商用");

        private int value;
        private String name;

        ApplicableScope(int value, String name) {
            this.value = value;
            this.name = name;
        }

        public String getName() {
            return name;
        }

        public int getValue() {
            return value;
        }

        public static JSONObject toJson(){
            JSONObject jsonObject = new JSONObject(values().length);
            for (ApplicableScope item : values())
                jsonObject.put(String.valueOf(item.getValue()), item.getName());
            return jsonObject;
        }
    }

    /**
     * 加热方式
     */
    public enum HeatingMethod{
        J(1, "即热"),
        X(2, "蓄热"),
        Z(3, "综合"),
        OTHER(4, "其他");

        private int value;
        private String name;

        HeatingMethod(int value, String name) {
            this.value = value;
            this.name = name;
        }

        public String getName() {
            return name;
        }

        public int getValue() {
            return value;
        }

        public static JSONObject toJson(){
            JSONObject jsonObject = new JSONObject(values().length);
            for (HeatingMethod item : values())
                jsonObject.put(String.valueOf(item.getValue()), item.getName());
            return jsonObject;
        }
    }

    /**
     * 类型
     */
    public enum Type{
        SMART(1, "智能"),
        NON_SMART(2, "非智能");

        private int value;
        private String name;

        Type(int value, String name) {
            this.value = value;
            this.name = name;
        }

        public String getName() {
            return name;
        }

        public int getValue() {
            return value;
        }

        public static JSONObject toJson(){
            JSONObject jsonObject = new JSONObject(values().length);
            for (Type item : values())
                jsonObject.put(String.valueOf(item.getValue()), item.getName());
            return jsonObject;
        }
    }

    public DeviceAttr setId(Long id){
        return this.set("id", id);
    }

    public Long getId(){
        return this.get("id");
    }
        
    public DeviceAttr setModelNum(String modelNum){
        return this.set("model_num",modelNum);
    }

    public String getModelNum(){
        return this.getStr("model_num");
    }
        
    public DeviceAttr setProjectId(Long projectId){
        return this.set("project_id", projectId);
    }

    public Long getProjectId(){
        return this.get("project_id");
    }
        
    public DeviceAttr setDescription(String description){
        return this.set("description",description);
    }

    public String getDescription(){
        return this.getStr("description");
    }
        
    public DeviceAttr setHeatingMethod(Integer heatingMethod){
        return this.set("heating_method",heatingMethod);
    }

    public Integer getHeatingMethod(){
        return this.get("heating_method");
    }

    public DeviceAttr setType(Integer type){
        return this.set("type",type);
    }

    public Integer getType(){
        return this.get("type");
    }
        
    public DeviceAttr setApplicableScope(Set applicableScope){
        return this.set("applicable_scope",applicableScope);
    }

    public String getApplicableScope(){
        return this.get("applicable_scope");
    }
        
    public DeviceAttr setCommunicatingMethod(String communicatingMethod){
        return this.set("communicating_method",communicatingMethod);
    }

    public String getCommunicatingMethod(){
        return this.get("communicating_method");
    }
        
    public DeviceAttr setDefaultConnectionStatus(Integer defaultConnectionStatus){
        return this.set("default_connection_status",defaultConnectionStatus);
    }

    public Integer getDefaultConnectionStatus(){
        return this.get("default_connection_status");
    }
        
    public DeviceAttr setHardwareVersionId(Long hardwareVersionId){
        return this.set("hardware_version_id",hardwareVersionId);
    }

    public Long getHardwareVersionId(){
        return this.get("hardware_version_id");
    }
        
    public DeviceAttr setAppVersionId(Integer appVersionId){
        return this.set("app_version_id",appVersionId);
    }

    public Integer getAppVersionId(){
        return this.get("app_version_id");
    }
        
    public DeviceAttr setCertificateId(Long certificateId){
        return this.set("certificate_id",certificateId);
    }

    public Long getCertificateId(){
        return this.get("certificate_id");
    }

    public DeviceAttr setReleaseDate(Date releaseDate){
        return this.set("release_date",releaseDate);
    }

    public Date getReleaseDate(){
        return this.get("release_date");
    }

    public DeviceAttr setPicUrl(String picUrl){
        return this.set("pic_url",picUrl);
    }

    public String getPicUrl(){
        return this.get("pic_url");
    }
}